const AVAILABLE_COINS: [u32; 8] = [1, 2, 5, 10, 20, 30, 50, 100];

pub fn dp_rec_mc(amount: u32) -> u32 {
    // Using dynamic programming, state transition equation:
    // min_coins[0] = 0;
    // min_coins[i] = min {
    //     (min_coins[i - coin] + 1)
    //         for each coin in AVAILABLE_COINS
    //             where coin <= i
    // }
    let amount = amount as usize;

    // Initialize the array to store the minimum number of coins for each amount.
    let mut min_coins = vec![u32::MAX; amount + 1];

    // Base case
    min_coins[0] = 0;

    for i in 1..=amount {
        for &coin in &AVAILABLE_COINS {
            if coin <= i as u32 {
                min_coins[i] = min_coins[i].min(min_coins[i - coin as usize] + 1);
            }
        }
    }

    min_coins[amount]
}
